/*
 *    Copyright (c) 2018-2025, lengleng All rights reserved.
 *
 * Redistribution and use in source and binary forms, with or without
 * modification, are permitted provided that the following conditions are met:
 *
 * Redistributions of source code must retain the above copyright notice,
 * this list of conditions and the following disclaimer.
 * Redistributions in binary form must reproduce the above copyright
 * notice, this list of conditions and the following disclaimer in the
 * documentation and/or other materials provided with the distribution.
 * Neither the name of the pig4cloud.com developer nor the names of its
 * contributors may be used to endorse or promote products derived from
 * this software without specific prior written permission.
 * Author: lengleng (wangiegie@gmail.com)
 */

package com.pig4cloud.pigx.contract.mapper;

import com.pig4cloud.pigx.common.data.datascope.PigxBaseMapper;
import com.pig4cloud.pigx.contract.dto.AppContractCurrentOrderConditionDTO;
import com.pig4cloud.pigx.contract.entity.ContractOrder;
import com.pig4cloud.pigx.contract.vo.AppContractCurrentOrderVO;
import org.apache.ibatis.annotations.Mapper;
import org.springframework.stereotype.Component;

import java.util.List;

/**
 * 订单表
 *
 * @since 2022-08-11 10:08:11
 */
@Mapper
@Component
public interface ContractOrderMapper extends PigxBaseMapper<ContractOrder> {

    /**
     * 撤销订单
     *
     * @param order 订单
     * @return {@link int}
     * @since 2022/8/18 21:59
     */
    int cancel(ContractOrder order);

    /**
     * 根据用户查询可以撤销的订单idList
     *
     * @param userId 用户id
     * @return {@link List< Long>}
     * @since 2022/10/11 09:34
     */
    List<Long> getNeedCancelOrderIdList(Long userId);

    /**
     * 批量撤销
     *
     * @param orderIds 订单ids
     * @return {@link int}
     * @since 2022/9/3 21:20
     */
    int cancelBatch(Long[] orderIds);

    /**
     * 过期
     *
     * @param order 订单
     * @return {@link int}
     * @since 2022/9/6 11:34
     */
    int expire(ContractOrder order);

    /**
     * app查询当前委托
     *
     * @param condition 查询条件
     * @return {@link List< AppContractCurrentOrderVO>}
     * @since 2022/8/26 18:28
     */
    List<AppContractCurrentOrderVO> appListCurrentOrder(AppContractCurrentOrderConditionDTO condition);

    /**
     * 获取交易用户量
     *
     * @return
     */
    Integer getTransactionUser();

    /**
     * 有客户自定义订单id，需要确保id唯一
     *
     * @param entity 订单数据
     * @return {@link int}
     * @since 2023/1/9 18:34
     */
    int insertClientOrderId(ContractOrder entity);
}
